package com.reactim.message.service;

import com.reactim.message.dto.ConversationResponse;
import com.reactim.message.dto.MessageResponse;
import com.reactim.message.dto.SendMessageRequest;
import com.reactim.message.entity.Message;
import org.springframework.data.domain.Pageable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 消息服务接口
 */
public interface MessageService {
    
    /**
     * 发送消息
     */
    Mono<MessageResponse> sendMessage(SendMessageRequest request);
    
    /**
     * 获取消息详情
     */
    Mono<MessageResponse> getMessageById(String messageId);
    
    /**
     * 获取会话消息列表
     */
    Flux<MessageResponse> getConversationMessages(String conversationId, Pageable pageable);
    
    /**
     * 获取私聊消息列表
     */
    Flux<MessageResponse> getPrivateMessages(Long userId1, Long userId2, Pageable pageable);
    
    /**
     * 获取群聊消息列表
     */
    Flux<MessageResponse> getGroupMessages(Long groupId, Pageable pageable);
    
    /**
     * 撤回消息
     */
    Mono<MessageResponse> recallMessage(String messageId, Long userId);
    
    /**
     * 删除消息
     */
    Mono<Void> deleteMessage(String messageId, Long userId);
    
    /**
     * 编辑消息
     */
    Mono<MessageResponse> editMessage(String messageId, Long userId, Message.MessageContent newContent);
    
    /**
     * 标记消息已读
     */
    Mono<Void> markMessageAsRead(String messageId, Long userId);
    
    /**
     * 批量标记消息已读
     */
    Mono<Void> markMessagesAsRead(List<String> messageIds, Long userId);
    
    /**
     * 获取未读消息数量
     */
    Mono<Long> getUnreadMessageCount(Long userId);
    
    /**
     * 搜索消息
     */
    Flux<MessageResponse> searchMessages(String keyword, Long userId, Pageable pageable);
    
    /**
     * 转发消息
     */
    Mono<MessageResponse> forwardMessage(String originalMessageId, Long fromUserId, Long toUserId, Long groupId);
    
    /**
     * 获取消息已读状态
     */
    Mono<List<Long>> getMessageReadUsers(String messageId);
    
    /**
     * 获取指定时间后的消息
     */
    Flux<MessageResponse> getMessagesAfter(String conversationId, LocalDateTime afterTime);
    
    /**
     * 获取指定序号后的消息
     */
    Flux<MessageResponse> getMessagesAfterSequence(String conversationId, Long sequence);
}